package com.erp.commands.login
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.erp.business.login.LoginDelegate;
	import com.erp.commands.BaseCommand;
	import com.erp.control.BaseEvent;
	import com.erp.model.login.LoginModelLocator;
	import com.erp.vo.ErpbaseUser;

	import mx.controls.Alert;
	import mx.rpc.IResponder;

	public class LoginCommand implements ICommand, IResponder
	{
		public function LoginCommand()
		{
		}

		public function execute(event:CairngormEvent):void
		{
			var baseEvent:BaseEvent=BaseEvent(event);
			var user:ErpbaseUser=baseEvent.data;
			var delegate:LoginDelegate=new LoginDelegate(this);
			delegate.login(user);
		}

		public function result(event:Object):void
		{
			var loginFlg:Boolean=event.result as Boolean;
			LoginModelLocator.getInstance().changeStack(loginFlg);
		}

		public function fault(event:Object):void
		{
			Alert.show("aaerror");
		}
	}
}